<!--************************************************************************************************-->
<!-- < addCommentResult.php >                                                                           -->
<!-- Copyright (c) 2012-2013 San Yat-sun University School of Software                              -->
<!-- Founder : Tianjiao Li                                                                          -->
<!-- Stu : 10389129                                                                                 -->
<!-- Date: 2013-01-01                                                                               -->
<!-- Destription : New one。                                                                                                                                                                                                                                                              -->
<!-- Basic: User:root                                                                               -->
<!--	    Password:                                                                               -->
<!-- Version : 2.1                                                                                  -->
<!-- LastUpdate : 2013-1-2 13:41 BY Tianjiaoli                                                       -->
<!--************************************************************************************************-->


<!DOCTYPE html>
<?php
	include_once("../manager/CommentManager.php");
	include_once("../db/Comment.php");
	include_once("header.php");
	//include_once("bottom.php");
?>
<html lang="zh-hk">
	<?php
	
	$flag = 0;
	if( isset($_POST['content'])) 
	{
		$content = $_POST['content'];
		$Username = $_SESSION['currentUser']; 
		$type = $_SESSION['currentType'];
		$date = date('Y-m-d H:i:s',time());
		
		if($type === "Thesis")
		{
			$Thesisname = $_REQUEST['thesis_name'];
			$array = array('content'=>$content,'Thesisname'=>$Thesisname, 'Username'=>$Username, 'date'=>$date);
		}
		if($type === "Book")
		{
			$Bookname = $_REQUEST['book_name'];
			$array = array('content'=>$content, 'Bookname'=>$Bookname,'Username'=>$Username, 'date'=>$date);
		}
		CommentManager::getInstance()->insert($array);
		
		$flag = 1;
	}

	?>
	
	<head>
		<title>TINY bOOk</title>
		<meta http-equiv="content-type" content="text/html;charset=UTF-8">
		<meta name="contentType" value="text/html  charset=GBK">
		<link rel="stylesheet" type="text/css" href="../css/result.css"/>
		<link rel="shortcut icon" href="images/shortcut.jpg"/>
		<?php
			if ($flag === 1)
			{
				if($type === "Thesis")
				{
		?>
					<meta http-equiv="refresh" content="1; url=thesisPage.php?thesis_name=<?=$Thesisname?>">
		<?php
			}
				if($type === "Book")
				{
		?>
					<meta http-equiv="refresh" content="1; url=bookPage.php?book_name=<?=$Bookname?>">
		<?php
				}
			}
		?>
	</head>	
		
	<body>
		<div id="result">
		<?php
			if ($flag === 1){
		?>
				<p>已成功上传评论，跳转到页面</p>
		<?php
			}
			else
			{
		?>
				<p>无法加载评论，返回页面</p>
		<?php
			}
		?>
		</div>
	</body>
</html>